Crate terminal_size[][src]

Expand description

A simple utility for getting the size of a terminal.

Supports both Linux, MacOS, and Windows.

This crate requires a minimum rust version of 1.31.0 (2018-12-06)

Example

use terminal_size::{Width, Height, terminal_size};

let size = terminal_size();
if let Some((Width(w), Height(h))) = size {
    println!("Your terminal is {} cols wide and {} lines tall", w, h);
} else {
    println!("Unable to get terminal size");
}

Structs

Height
Width

Functions

terminal_size

Returns the size of the terminal defaulting to STDOUT, if available.

terminal_size_using_fd

Returns the size of the terminal using the given file descriptor, if available.